package com.powernode.controller;

import com.powernode.dto.Result;
import com.powernode.util.MinioUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/pms/admin/oss")
public class AdminOssController {
    @Autowired
    private MinioUtil minioUtil;

    /**
     * 上传商品图片到云存储
     */
    @PostMapping("upload")
    public Result upload(MultipartFile file,String directory){
        return minioUtil.upload(file,directory);
    }

    /**
     * 删除图片从云存储
     */
    @DeleteMapping("remove")
    public Result remove(@RequestParam("file") String filename){
        return minioUtil.removeFile(filename);
    }
    /**
     * 批量删除图片从云存储
     */
    @DeleteMapping("removeBatch")
    public Result removeBatch(@RequestParam List<String> files){
        return minioUtil.removeBatch(files);
    }
}
